From b6fda5dc0a847c582f53d984f439c4e449797f33 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 31 Oct 2015 00:07:19 -0400 Subject: [PATCH] inspector: Show CSS node state This is useful when debugging state propagation issues between CSS nodes. --- gtk/inspector/css-node-tree.c | 36 ++++++++++++++++++++++++++++++++++ gtk/inspector/css-node-tree.ui | 13 ++++++++++++ 2 files changed, 49 insertions(+) diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c index 0d322aa1c3..b68c53e4eb 100644 --- a/gtk/inspector/css-node-tree.c +++ b/gtk/inspector/css-node-tree.c @@ -40,6 +40,7 @@ #include "gtksettings.h" #include "gtktreeview.h" #include "gtktreeselection.h" +#include "gtktypebuiltins.h" enum { COLUMN_NODE_NAME, @@ -47,6 +48,7 @@ enum { COLUMN_NODE_VISIBLE, COLUMN_NODE_CLASSES, COLUMN_NODE_ID, + COLUMN_NODE_STATE, /* add more */ N_NODE_COLUMNS }; @@ -194,6 +196,35 @@ strv_sort (char **strv) NULL); } +static gchar * +format_state_flags (GtkStateFlags state) +{ + GFlagsClass *fclass; + GString *str; + gint i; + + str = g_string_new (""); + + if (state) + { + fclass = g_type_class_ref (GTK_TYPE_STATE_FLAGS); + for (i = 0; i < fclass->n_values; i++) + { + if (state & fclass->values[i].value) + { + if (str->len) + g_string_append (str, " | "); + g_string_append (str, fclass->values[i].value_nick); + } + } + g_type_class_unref (fclass); + } + else + g_string_append (str, "normal"); + + return g_string_free (str, FALSE); +} + static void gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model, GtkCssNode *node, @@ -229,6 +260,10 @@ gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model, g_value_set_string (value, gtk_css_node_get_id (node)); break; + case COLUMN_NODE_STATE: + g_value_take_string (value, format_state_flags (gtk_css_node_get_state (node))); + break; + default: g_assert_not_reached (); break; @@ -251,6 +286,7 @@ gtk_inspector_css_node_tree_init (GtkInspectorCssNodeTree *cnt) G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING); gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_tree), priv->node_model); g_object_unref (priv->node_model); diff --git a/gtk/inspector/css-node-tree.ui b/gtk/inspector/css-node-tree.ui index 35a956c296..45fd673bfd 100644 --- a/gtk/inspector/css-node-tree.ui +++ b/gtk/inspector/css-node-tree.ui @@ -93,6 +93,19 @@ + + + 1 + State + + + + 5 + 2 + + + + -- 2.30.2